package one.stand.controller;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.AppointmentRequest;
import one.stand.request.ProductsRequest;
import one.stand.request.ProductsTypeRequest;
import one.stand.response.AppointmentResponse;
import one.stand.response.ProductsResponse;
import one.stand.response.ProductsTypeResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 产品信息管理
 * @author Administrator
 */
@RestController
@RequestMapping("crmApi/products")
public class ProductsController extends BaseController {

    @PostMapping("/getProductsCount")
    @ApiOperation(value = "根据公司ID查询预约管理中预约列表数和产品管理数")
    @ApiController(isLogin = true,company = true,card = true,paramClass = AppointmentRequest.class )
    public ResultModel<Map<String, Object>> getProductsCount(@RequestAttribute AppointmentRequest request) {
        return crmFegin.getProductsCount(request);
    }

    @PostMapping("/selectProductsTypeList")
    @ApiOperation(value = "查询公司预约商品类型（下拉框显示）")
    @ApiController(isLogin = true,company = true,card = true,paramClass = ProductsTypeRequest.class )
    public ResultModel<List<ProductsTypeResponse>> selectProductsTypeList(@RequestAttribute ProductsTypeRequest request) {
        return crmFegin.selectProductsTypeList(request);
    }

    @PostMapping("/selectProductsTypePage")
    @ApiOperation(value = "分页查询公司预约商品类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "productsTypeName", value = "预约商品类型名称", paramType = "String"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = ProductsTypeRequest.class )
    public ResultModel<Map<String, Object>> selectProductsTypePage(@RequestAttribute ProductsTypeRequest request) {
        return crmFegin.selectProductsTypePage(request);
    }

    @PostMapping("/selectProductsType")
    @ApiOperation(value = "查询公司预约商品类型（包含类型下的商品信息）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsTypeName", value = "预约商品类型名称", paramType = "String"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = ProductsTypeRequest.class )
    public ResultModel<List<ProductsTypeResponse>> selectProductsType(@RequestAttribute ProductsTypeRequest request) {
        return crmFegin.selectProductsType(request);
    }

    @PostMapping("/insertProductsType")
    @ApiOperation(value = "新增/修改预约商品类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsTypeId", value = "预约商品类型id", paramType = "Integer"),
            @ApiImplicitParam(name = "productsTypeName", value = "预约商品类型名称", required = true, paramType = "String"),
    })
    @ApiController(isLogin = true, company = true, card = true, isBoss = true, paramClass = ProductsTypeRequest.class )
    public ResultModel<Boolean> insertProductsType(@RequestAttribute ProductsTypeRequest request) {
        return crmFegin.insertProductsType(request);
    }

    @PostMapping("/delProductsType")
    @ApiOperation(value = "删除预约商品类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsTypeId", value = "预约商品类型id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,isBoss = true, paramClass = ProductsTypeRequest.class )
    public ResultModel<Boolean> delProductsType(@RequestAttribute ProductsTypeRequest request) {
        return crmFegin.delProductsType(request);
    }

    @PostMapping("/moveProductsType")
    @ApiOperation(value = "上移/下移商品类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsTypeId", value = "预约商品类型id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "type", value = "1 上移  2下移", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,isBoss = true, paramClass = ProductsTypeRequest.class )
    public ResultModel<Boolean> moveProductsType(@RequestAttribute ProductsTypeRequest request) {
        return crmFegin.moveProductsType(request);
    }

    @PostMapping("/selectProductsPage")
    @ApiOperation(value = "分页查询公司预约商品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "productsTypeId", value = "预约商品类型id（不传查询全部商品）", paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = ProductsRequest.class )
    public ResultModel<Map<String, Object>> selectProductsPage(@RequestAttribute ProductsRequest request) {
        return crmFegin.selectProductsPage(request);
    }

    @PostMapping("/getProductsInfo")
    @ApiOperation(value = "查询公司预约商品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsId", value = "预约商品id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = ProductsRequest.class )
    public ResultModel<ProductsResponse> getProductsInfo(@RequestAttribute ProductsRequest request) {
        return crmFegin.getProductsInfo(request);
    }

    @PostMapping("/insertProducts")
    @ApiOperation(value = "新增/修改预约商品的信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsId", value = "预约商品id", paramType = "Integer"),
            @ApiImplicitParam(name = "productsTypeId", value = "预约商品类型id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "productsName", value = "预约商品名称", required = true, paramType = "String"),
            @ApiImplicitParam(name = "price", value = "预约商品价格", required = true, paramType = "String"),
            @ApiImplicitParam(name = "describe", value = "预约商品描述", required = true, paramType = "String"),
            @ApiImplicitParam(name = "sharePhoto", value = "预约商品分享图片", required = true, paramType = "String"),
            @ApiImplicitParam(name = "isPayment", value = "1是线上支付 2其他", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "serviceType", value = "服务类型：1到店服务，2上门服务，3全部", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "remark", value = "备注", required = true, paramType = "String"),
            @ApiImplicitParam(name = "productsPhoto", value = "预约商品图片（逗号隔开）", required = true, paramType = "String"),
            @ApiImplicitParam(name = "productsDetails", value = "预约商品详情", required = true, paramType = "String"),
    })
    @ApiController(isLogin = true,company = true,card = true,isBoss = true,paramClass = ProductsRequest.class )
    public ResultModel<Boolean> insertProducts(@RequestAttribute ProductsRequest request) {
        return crmFegin.insertProducts(request);
    }

    @PostMapping("/delProducts")
    @ApiOperation(value = "删除预约商品的信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsId", value = "预约商品id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = ProductsRequest.class )
    public ResultModel<Boolean> delProducts(@RequestAttribute ProductsRequest request) {
        return crmFegin.delProducts(request);
    }

    @PostMapping("/moveProducts")
    @ApiOperation(value = "上移/下移预约商品")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsId", value = "预约商品id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "type", value = "1 上移  2下移", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = ProductsRequest.class )
    public ResultModel<Boolean> moveProducts(@RequestAttribute ProductsRequest request) {
        return crmFegin.moveProducts(request);
    }

    @PostMapping("/selectAppointmentPage")
    @ApiOperation(value = "分页查询预约列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "state", value = "1进行中，2已完成，3已取消", paramType = "Integer"),
            @ApiImplicitParam(name = "createTimes", value = "下单时间", paramType = "String"),
            @ApiImplicitParam(name = "startTimes", value = "预约开始时间", paramType = "String"),
            @ApiImplicitParam(name = "endTimes", value = "预约结束时间", paramType = "String"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = AppointmentRequest.class )
    public ResultModel<Map<String, Object>> selectAppointmentPage(@RequestAttribute AppointmentRequest request) {
        return crmFegin.selectAppointmentPage(request);
    }

    @PostMapping("/getAppointmentInfo")
    @ApiOperation(value = "查询预约列表详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "appointmentId", value = "预约id", required = true,paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = AppointmentRequest.class )
    public ResultModel<AppointmentResponse> getAppointmentInfo(@RequestAttribute AppointmentRequest request) {
        return crmFegin.getAppointmentInfo(request);
    }

    @PostMapping("/insertAppointment")
    @ApiOperation(value = "新增预约订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsId", value = "产品id", required = true,paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true,paramType = "Integer"),
            @ApiImplicitParam(name = "name", value = "姓名", required = true,paramType = "String"),
            @ApiImplicitParam(name = "phone", value = "电话", required = true,paramType = "String"),
            @ApiImplicitParam(name = "startTimes", value = "预约开始时间（yyyy-mm-dd hh:mm）", required = true,paramType = "String"),
            @ApiImplicitParam(name = "endTimes", value = "预约结束时间（yyyy-mm-dd hh:mm）", required = true,paramType = "String"),
            @ApiImplicitParam(name = "remark", value = "备注", required = true,paramType = "String"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = AppointmentRequest.class )
    public ResultModel<Boolean> insertAppointment(@RequestAttribute AppointmentRequest request) {
        return crmFegin.insertAppointment(request);
    }

    @PostMapping("/updAppointmentState")
    @ApiOperation(value = "修改预约订单状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "appointmentId", value = "预约id", required = true,paramType = "Integer"),
            @ApiImplicitParam(name = "state", value = "1进行中，2已完成，3已取消，4已过期", required = true,paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = AppointmentRequest.class )
    public ResultModel<Boolean> updAppointmentState(@RequestAttribute AppointmentRequest request) {
        return crmFegin.updAppointmentState(request);
    }
}
